package com.itheima.tliasmanager.aop;


import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class RecordTimeAspect {

    @Pointcut("execution(public * com.itheima.tliasmanager.service.Impl.EmpServiceImpl.*(..))")
    public void pt(){}

    @Around("pt()")

    public Object recordTime(ProceedingJoinPoint pjp) throws Throwable {
        // 开始时间
        long start = System.currentTimeMillis();
        // 执行方法
        Object result = pjp.proceed();
        // 结束时间
        long end = System.currentTimeMillis();
        // 获取方法名
        String methondName = pjp.getSignature().getName();
        // 打印耗时
        System.out.println(methondName+"----*>耗时："+(end-start));
        return result;
    }
}
